package com.kevin.controller;

import com.kevin.IProductService;
import com.kevin.IUserService;
import com.kevin.annotation.RemoteReference;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class RpcTestController {

    @RemoteReference
    private IUserService iUserService;

    @RemoteReference
    private IProductService productService;


    @GetMapping("/test")
    public String test(String name){
        log.info("request name={}",name);
        return iUserService.getName(name);
    }

    @GetMapping("/product/{id}")
    public String productName(@PathVariable String id){
        return productService.getNameByid(id);
    }
}
